{% extends "tj3/tj3.html" %}

{% block navigation %}
	<script type="text/javascript">
		$('document').ready(function(){
			$('#my_tabs').tabs();
		});
	</script>
{% endblock navigation %}

{% block content  %} 
<h1 class="ui-widget ui-widget-header">{{project.name}}<span class="float_right">Scenario: {{scenario.name|capfirst}}</h1>
{% if stderr|length %}
	<div class="ui-state-error">
	The rebalance failed. See the errors page for details. You need to reconcile the conflicts and
	rebalance the project again. Go to the <b><a href="{%url project_main_plan project.id%}">Project Plan</a></b> to fine tune
	your project plan.
	</div>
{% else %}
	It appeared that the rebalance ran successfully. There were {{ warnings|length }} warnings. 
	Go to the <b><a href="{% url project_main_actual project.id, scenario.id%}">Execution Central</a></b>
	to examine the project execution!
{% endif %}

<div id="my_tabs">
	<ul>
		<li><a href="#stdout">Command Outputs</a></li>
		<li><a href="#stderr">Errors and Warnings</a></li>
		<li><a href="#tjp">TJP & TJI</a></li>
		<li><a href="#report">Reports</a></li>
	</ul>

	<div id="stdout">
		<div>
			<pre>
				{{stdout}}
			</pre>
		</div>
	</div>

	<div id="stderr">
		<div>
			<h2 class="ui-corner-all ui-state-error">Errors</h2>
				{% if error_parsed %}
					{% for e in errors %}
						<h4>
							<span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"></span>
							{% if e.task %}
								<a href={% url task_detail e.task.id %}>{{e.task.name}}</a>
							{% else %}
								task unknown
							{% endif %}
							<span class="float_right">{{e.scenario.name}}</span>
						</h4>
						
						Line {{e.lineno}} in <span class="fancy">{{e.filename}}</span>:
						<blockquote class="span-12 ui-corner-all">
							{{e.msg}}
						</blockquote>
					{% endfor %}
				<h2 class="ui-state-highlight ui-corner-all">Warnings</h2>
					{% for e in warnings %}
						<h4>
							<span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"></span>
							{% if e.task %}
								<a href={% url task_detail e.task.id %}>{{e.task.name}}</a>
							{% else %}
								task unknown
							{% endif %}
							<span class="float_right">{{e.scenario.name}}</span>
						</h4>
						
						Line {{e.lineno}} in <span class="fancy">{{e.filename}}</span>:
						<blockquote class="span-12 ui-corner-all">
							{{e.msg}}
						</blockquote>
					{% endfor %}
				
				{% else %}				
					<div>
						<pre>
							{{stderr}}
						</pre>
					</div>
				{% endif %}
			</div>
	</div>

	<div id="tjp">
		<h2 class="ui-state-highlight ui-corner-all">Main TJP</h2>
		<div class="mycontent"><pre>{{tjp|safe}}</pre></div>

		<h2 class="ui-state-highlight ui-corner-all">Resource TJI</h2>
		<div class="mycontent">
			<pre>{{resource_tji|safe}}</pre>
		</div>
	
		<h2 class="ui-state-highlight ui-corner-all">Task TJI</h2>
		<div class="mycontent">
			<pre>{{task_tji|safe}}</pre>
		</div>
		
		<h2 class="ui-state-highlight ui-corner-all">Journal TJI</h2>
		<div class="mycontent">
			<pre>{{journal_tji}}</pre>
		</div>

		<h2 class="ui-state-highlight ui-corner-all">Report TJI</h2>
		<div class="mycontent">
			<pre>{{report_tji}}</pre>
		</div>		
	</div>
	
	<div id="report">
		<div class="mycontent">
		<ul>
		{% for r in reports %}
			<li><a href={% url report_display r.id %}>{{r.template.name}}</a>
		{% endfor %}
		<ul>
		</div>
	</div>
</div>
{% endblock content %}
